package com.lee.net;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.DefaultHttpClient;

public class HttpHelper
{

	public static String readResponse(HttpEntity entity) throws Exception
	{
		String str = "";
		String line = null;
		BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));
		while ((line = reader.readLine()) != null)
		{
			str += line;
			str += "\n";
		}
		str = new String(str.getBytes(), "utf-8");
		return str;
	}

	public static void printCookies(DefaultHttpClient client)
	{
		List<Cookie> cookies = client.getCookieStore().getCookies();
		
		System.out.println("---------------current cookies---------------");
		for(int i = 0; i < cookies.size(); i++)
		{
			System.out.println(cookies.get(i).getName() + " : " 
						+ cookies.get(i).getValue());
		}
		System.out.println("---------------current cookies---------------");
	}
	
}
